/**
 * 订单API接口
 */
import api from './chat'

export interface OrderQueryResponse {
  success: boolean
  order?: any
  message?: string
}

export interface OrderListResponse {
  success: boolean
  orders: any[]
  total: number
}

export interface LogisticsResponse {
  success: boolean
  logistics?: any
  message?: string
}

export interface RefundRequest {
  order_sn: string
  reason: string
}

export interface RefundResponse {
  success: boolean
  message: string
  refund_id?: string
  estimated_time?: string
}

/**
 * 查询订单详情
 */
export const queryOrder = (orderSn: string): Promise<OrderQueryResponse> => {
  return api.get(`/orders/query/${orderSn}`)
}

/**
 * 获取订单列表
 */
export const getOrderList = (params?: {
  status?: string
  limit?: number
}): Promise<OrderListResponse> => {
  return api.get('/orders/list', { params })
}

/**
 * 查询物流信息
 */
export const queryLogistics = (orderSn: string): Promise<LogisticsResponse> => {
  return api.get(`/orders/logistics/${orderSn}`)
}

/**
 * 申请退款
 */
export const applyRefund = (data: RefundRequest): Promise<RefundResponse> => {
  return api.post('/orders/refund', data)
}

